package com.weibo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

import com.weibo.service.WeiboCommentService;
import com.weibo.entity.WeiboComment;

/**
 * WeiboComment的路由接口服务
 * 
 * @author 
 *
 */
@RestController
public class WeiboCommentController {

	/** WeiboCommentService服务 */
	@Autowired
	private WeiboCommentService weiboCommentService;
	
	/**
	 * 查询所有WeiboComment数据的方法
	 * @param value
	 * @return
	 */
	@GetMapping(value = "/WeiboComment", produces = {"application/json;charset=UTF-8"})
	public String find(WeiboComment value) {
		//System.out.println("aaaaa");
		//value.setUserId("7846354946");
		String res  =weiboCommentService.find(value);
		return res;
	}

	@GetMapping(value = "/group", produces = {"application/json;charset=UTF-8"})
	public String group(WeiboComment value) {
		//System.out.println("aaaaa");
		//value.setUserId("7846354946");
		String res  =weiboCommentService.group(value);
		return res;
	}
	
	/**
	 * 通过id查询WeiboComment数据的方法
	 * @param id
	 * @return
	 */
	@GetMapping(value = "/WeiboComment/{id}", produces = {"application/json;charset=UTF-8"})
	public String findOne(@PathVariable(name="id") String id) {
		return weiboCommentService.findOne(id);
	}
	
	/**
	 * 插入WeiboComment属性不为空的数据方法
	 * @param id
	 * @return
	 */
	@PostMapping(value = "/WeiboComment", produces = {"application/json;charset=UTF-8"})
	public String save(WeiboComment value) {
		return weiboCommentService.saveNotNull(value);
	}
	
	/**
	 * 更新WeiboComment属性不为空的数据方法
	 * @param id
	 * @return
	 */
	@PutMapping(value = "/WeiboComment", produces = {"application/json;charset=UTF-8"})
	public String update(WeiboComment value) {
		return weiboCommentService.updateNotNullById(value);
	}
	
	/**
	 * 通过id删除WeiboComment数据方法
	 * @param id
	 * @return
	 */
	@DeleteMapping(value = "/WeiboComment/{id}", produces = {"application/json;charset=UTF-8"})
	public String delete(@PathVariable(name="id") String id) {
		return weiboCommentService.deleteById(id);
	}
}
